package cn.hg.jbsa.admin.service;

import java.util.List;

import com.jfinal.kit.Kv;
import com.jfinal.plugin.activerecord.Page;

import cn.hg.jboot.core.exception.BaseServiceException;
import cn.hg.jbsa.admin.model.JbsaAdmin;
import cn.hg.jbsa.admin.model.JbsaResource;
import io.jboot.db.model.Columns;

public interface JbsaResourceService  {

    /**
     * 根据 多个 id 批量删除
     *
     * @param ids
     * @return
     */
    public boolean batchDeleteByIds(Object... ids);


    List<JbsaResource> buildTree (final List<JbsaResource> list, Integer... parentIds) throws BaseServiceException;

    /**
     * 删除
     *
     * @param model
     * @return
     */
    public boolean delete(JbsaResource model);

    /**
     * 根据ID 删除model
     *
     * @param id
     * @return
     */
    public boolean deleteById(Object id);


    List<JbsaResource> findActionByAdmin (JbsaAdmin admin, String status);


    /**
     * 查找全部数据
     *
     * @return
     */
    public List<JbsaResource> findAll();

    /**
     * 根据主键查找Model
     *
     * @param id
     * @return
     */
    public JbsaResource findById(Object id);

    /**
     * 根据提交查询数据量
     *
     * @param columns
     * @return
     */
    public long findCountByColumns(Columns columns);


    /**
     * 根据 Columns 查找单条数据
     *
     * @param columns
     * @return
     */
    public JbsaResource findFirstByColumns(Columns columns);


    /**
     * 根据 Columns 查找单条数据
     *
     * @param columns
     * @param orderBy
     * @return
     */
    public JbsaResource findFirstByColumns(Columns columns, String orderBy);


    /**
     * 根据 Columns 查找数据
     *
     * @param columns
     * @return
     */
    public List<JbsaResource> findListByColumns(Columns columns);


    /**
     * 根据 Columns 查找数据
     *
     * @param columns
     * @param count
     * @return
     */
    public List<JbsaResource> findListByColumns(Columns columns, Integer count);


    /**
     * 根据 Columns 查找数据
     *
     * @param columns
     * @param orderBy
     * @return
     */
    public List<JbsaResource> findListByColumns(Columns columns, String orderBy);

    /**
     * 根据 Columns 查找数据
     *
     * @param columns
     * @param orderBy
     * @param count
     * @return
     */
    public List<JbsaResource> findListByColumns(Columns columns, String orderBy, Integer count);

    List<JbsaResource> findMenuByAdmin (JbsaAdmin admin, String status, Integer... parentIds);

    List<JbsaResource> findPageByKv(Integer page, Integer limit, Kv para) throws BaseServiceException;

    List<JbsaResource> findTree (Integer... parentIds) throws BaseServiceException;

    /**
     * 分页
     *
     * @param page
     * @param pageSize
     * @return
     */
    public Page<JbsaResource> paginate(int page, int pageSize);

    /**
     * 分页
     *
     * @param page
     * @param pageSize
     * @return
     */
    public Page<JbsaResource> paginateByColumns(int page, int pageSize, Columns columns);


    /**
     * 分页
     *
     * @param page
     * @param pageSize
     * @param columns
     * @param orderBy
     * @return
     */
    public Page<JbsaResource> paginateByColumns(int page, int pageSize, Columns columns, String orderBy);


    /**
     * 保存到数据库
     *
     * @param model
     * @return id if success
     */
    public Object save(JbsaResource model);


    /**
     * 保存或更新
     *
     * @param model
     * @return id if success
     */
    public Object saveOrUpdate(JbsaResource model);


    /**
     * 更新
     *
     * @param model
     * @return
     */
    public boolean update(JbsaResource model);

    void updateChildredIds (JbsaResource resource);

    void updateStatus (JbsaResource resource, String status);
}
